using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Portal.BO.Editoral.NewsEditModules;

namespace Portal.GUI.EditoralOffice.MainOffce.NewsEditModules.ImagesModule
{
    public partial class Image : Portal.API.Module
    {
        protected void Page_Load(object sender, EventArgs e)
		{
            //if (!IsPostBack)
            //{
                LoadRuntimeSettings();
                imgMain.ImageUrl = Convert.ToString(ReadRuntimeConfig(true, "ImagePath"));
                if (!imgMain.ImageUrl.StartsWith("/") && !imgMain.ImageUrl.StartsWith("http://"))
                    imgMain.ImageUrl = "/" + imgMain.ImageUrl;
                lnkMain.NavigateUrl = Convert.ToString(ReadRuntimeConfig(true, "ImageLink"));
                lnkMain.Target = Convert.ToString(ReadRuntimeConfig(true, "ImageTargetType"));
                try
                {
                    double width = Convert.ToDouble(ReadRuntimeConfig(true, "ImageWidth"));
                    if (width > 0)
                        imgMain.Width = new Unit(width, UnitType.Pixel);
                    double height = Convert.ToDouble(ReadRuntimeConfig(true, "ImageHeight"));
                    if (height > 0)
                        imgMain.Height = new Unit(height, UnitType.Pixel);
                }
                catch { }

                imgMain.BorderWidth = new Unit(0);
                try
                {
                    double borderWidth = Convert.ToDouble(ReadRuntimeConfig(true, "ImageBorderWidth"));
                    if (borderWidth > 0)
                        imgMain.BorderWidth = new Unit(borderWidth, UnitType.Pixel);
                    string borderColor = Convert.ToString(ReadRuntimeConfig(true, "ImageBorderColor"));
                    if (borderColor != "")
                        imgMain.BorderColor = System.Drawing.Color.FromName(borderColor);
                }
                catch { }
            //}
        }
    }
}